#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>

bool isUglyNumber(long long n)//是否是丑数
{
    long long tmp = n;
    if(n == 0)
        return false;
    while(1)
    {
        if(tmp % 5 == 0)
            tmp /= 5;
        else if(tmp % 3 == 0)
            tmp /= 3;
        else if(tmp % 2 == 0)
            tmp /= 2;
        else
        {
            if(tmp == 1)
                return true;
            else
                return false;
        }
    }
}

long long* generateUglyNumbers(int n)
{
    long long i = 0;
    int count = 0;
    long long* arr = (long long*)malloc(n * sizeof(long long));
    while(count < n)
    {
        if(isUglyNumber(i))
        {
            arr[count] = i;
            count++;
            i++;
        }
        else
            i++;
    }

    return arr;
}

int main()
{
    long long n = 10;
    //isUglyNumber(n);
    long long* p = generateUglyNumbers(n);

    for(int i = 0; i < n; i++)
        printf("%lld ",p[i]);
    printf("\n");

    return 0;
}

